﻿package org.hsl.avm2.translation.progress;
/**
 * The progress of a load operation.
 */
class LoadProgress {
	/**
	 * The number of bytes that are loaded.
	 */
	public var numberOfBytesLoaded(default, null):UInt;
	/**
	 * The number of bytes that should be loaded.
	 */
	public var numberOfBytesTotal(default, null):UInt;
	/**
	 * The progress of the load operation as a number between 0 and 1, or Math.NaN if numberOfBytesTotal is equal to 0.
	 */
	public var progress(default, null):Float;
	/**
	 * Creates a new load progress. If numberOfBytesTotal is equal to 0, the progress property will be Math.NaN.
	 */
	public function new(numberOfBytesLoaded:UInt, numberOfBytesTotal:UInt):Void {
		this.numberOfBytesLoaded = numberOfBytesLoaded;
		this.numberOfBytesTotal = numberOfBytesTotal;
		if (numberOfBytesTotal != 0) {
			progress = numberOfBytesLoaded / numberOfBytesTotal;
		}
	}
	private function toString():String {
		return "[LoadProgress numberOfBytesLoaded=" + numberOfBytesLoaded + " numberOfBytesTotal=" + numberOfBytesTotal + " progress=" + progress + "]";
	}
}